//
//  DuoAccessory.h
//  duosample
//
//  Created by Lin Xu for Discovery Bay Games on 4/4/12.
//  Copyright (c) 2012 Discovery Bay Games. All rights reserved.
//


#import "input/duo/DuoAccessoryDevice.h"

// We use a struct here because we absolutely do not want to heap alloc
// potentially dozens of these a second
typedef struct _DuoInputPackV2
{
    bool buttonA;
    bool buttonB;
    bool buttonX;
    bool buttonY;
    
    bool buttonL;
    bool buttonR;
    bool buttonU;
    bool buttonD;
    
    bool buttonStart;
    
    int leftStick[2];
    int rightStick[2];
    
    bool buttonLeftStick;
    bool buttonRightStick;
        
    bool leftTrigger;
    bool rightTrigger;
} DuoInputPackV2;

@class DuoAccessoryV2;

@protocol DuoAccessoryDelegateV2 <NSObject>
@required
- (void) duoAccessory:(DuoAccessoryV2*)accessory didHaveInput:(DuoInputPackV2)package;
@end

@interface DuoAccessoryV2 : DuoAccessoryDevice
{
    NSMutableData *rxData;
    id<DuoAccessoryDelegateV2> _delegate;
    DuoInputPackV2 _inputPacket; 
}
@property (nonatomic, retain) id<DuoAccessoryDelegateV2> delegate;
//@property (nonatomic)  DuoInputPackV2 inputPacket;

@end

//Use this subclass if you want the stream to run on a specific run loop
@interface DuoThreadedAccessoryV2 : DuoAccessoryV2
{
        NSRunLoop* _loop;
}
- (id) initWithProtocol:(NSString *)protocol andRunLoop:(NSRunLoop*)loop;
@end
